#!/bin/sh
# ff-c++ `./ff-get-dep -ff metis.cpp`

case "$1" in
    -dlib)
	shift
	awk -F:  '/^[\/]+ff-c[+][+]-LIBRARY-dep:/  { printf("%s",$2); exit 0;}' $@
	exit 0; 
	;;
    -dcpp)
	shift
	awk -F:  '/^[\/]+ff-c[+][+]-cpp-dep:/  { printf("%s",$2); exit 0;}' $@
	exit 0; 
	;;
    -ff)
	shift;
#  ajout  de lib  with check
	libs=`$0 -dlib $@`
	cpp=`$0 -dcpp $@`" $@"
	;;
esac 
dircommand=`dirname $0`
if [   -f "WHERE_LIBRARY-download" ] ; then
dircommand="./"
elif [   -f "$dircommand/WHERE_LIBRARY-download" ] ; then
    dirwhere=$dircommand
elif [ -f '@ff_prefix_dir@/lib/WHERE_LIBRARY-download' ] ; then
    dirwhere='@ff_prefix_dir@/lib'
else
   echo " error no WHERE_LIBRARY  file "
   exit 1;
fi
cd "$dirwhere"
wherel=WHERE_LIBRARY-download
test -f WHERE_LIBRARY-config && wherel="$wherel  WHERE_LIBRARY-config"
test -f WHERE_LIBRARY && wherel="$wherel WHERE_LIBRARY"
awk -f ff-get-dep.awk -v libs="$libs"  -v cpp="$cpp" $wherel
exit $?
